<template>
    <div class="home">
    <el-container>
    <el-aside width="auto" style="height:100%">
        <div class="logo"></div>
         <el-menu
       
         :collapse="isCollapse"
      default-active="2"
      class="el-menu-admin"
      @open="handleOpen"
      @close="handleClose" 
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b" >
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>用户管理</span>
        </template>
        <el-menu-item index="2">
             <i class="el-icon-menu"></i>
            用户列表
        </el-menu-item>
     
        <!-- <el-menu-item-group title="分组2">
          <el-menu-item index="1-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="1-4">
          <template slot="title">选项4</template>
          <el-menu-item index="1-4-1">选项1</el-menu-item>
        </el-submenu> -->
      </el-submenu>
    </el-menu>
    </el-aside>
    <el-container>
        <el-header>
            <i class="myicon myicon-menu toggle-btn" @click="togglecollapse"></i>
            <div class="system-title">
                电商后台管理系统
            </div>
            <span class="welcome">
                你好,{{$store.getters.username}}
            </span>
              <el-button type="text" @click= "logout">退出</el-button>
        </el-header>
        <el-main><router-view></router-view></el-main>
    </el-container>
    </el-container>
    </div>
</template>
<script>
import { getusers } from "@/api";
export default {
    data () {
        return {
            isCollapse:false
        }
    },
        methods: {
      handleOpen(key, keyPath) {
        // console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        // console.log(key, keyPath);
      },
      togglecollapse(){
          this.isCollapse= !this.isCollapse
      },
      logout(){
          localStorage.removeItem("mytoken");
          this.$router.push({name:"login"})
      }
    },
    mounted(){
        let params = {params:{
            query:"",
            pagenum:1,
            pagesize:2
        }}
        getusers(params).then(res=>{
            // console.log(res)
        })
    }
}
</script>
<style lang="scss" scoped>
.home {
  height: 100%;
  background-color: #fff;
  .el-menu-admin:not(.el-menu--collapse) {
    width: 200px;
    // min-height: 400px;
    height:100%
  }
  .el-container {
    height: 100%;
  }
  .el-aside {
    background-color: #ccc;
  }
  .el-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ccc;
  }
  .logo {
    height:60px;
    background: url(../assets/logo.png);
    background-size: cover;
    background-color: white;
  }
  .toggle-btn {
    padding: 0 10px;
    margin-left: -20px;
    font-size: 36px;
    line-height: 60px;
    color: white;
    cursor: pointer;
    &:hover {
      background-color: #00635a;
    }
  }
  .system-title {
    font-size: 28px;
    color: white;
  }
  .welcome, {
    color: white;
  }
}
</style>


